package main

import "fmt"

func fibo(c, quit chan int) {
	x, y := 1, 1
	fmt.Println("test")
	for {
		//通过select判断处理通道
		select {
		case c <- x: //给c通道传值,1-son阻塞解开
			fmt.Println("main...") //main继续
			x = y
			y += x
		case <-quit:
			fmt.Println("quit")
			return
		}
	}
}

func main() {
	c := make(chan int)
	quit := make(chan int)

	go func() {
		for i := 0; i < 10; i++ {
			fmt.Println("son: ", <-c) //1-son阻塞
		}
		quit <- 0
	}()

	fibo(c, quit) //1-main执行
}
